package com.mall.web.controller.product;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.mall.common.annotation.Log;
import com.mall.common.enums.BusinessType;
import com.mall.product.domain.entity.ProProductCustomRecordValue;
import com.mall.product.service.ProProductCustomRecordValueService;
import com.mall.common.core.controller.BaseController;
import com.mall.common.core.domain.AjaxResult;
import com.mall.common.utils.poi.ExcelUtil;
import com.mall.common.core.page.TableDataInfo;

/**
 * 商品属性值对照Controller
 * 
 * @author zhonglin
 * @date 2020-05-07
 */
@Controller
@RequestMapping("/product/productCustomRecordValue")
public class ProProductCustomRecordValueController extends BaseController
{
    private String prefix = "product/productCustomRecordValue";

    @Autowired
    private ProProductCustomRecordValueService proProductCustomRecordValueService;

    @RequiresPermissions("product:productCustomRecordValue:view")
    @GetMapping()
    public String productCustomRecordValue()
    {
        return prefix + "/productCustomRecordValue";
    }

    /**
     * 查询商品属性值对照列表
     */
    @RequiresPermissions("product:productCustomRecordValue:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProProductCustomRecordValue proProductCustomRecordValue)
    {
        startPage();
        List<ProProductCustomRecordValue> list = proProductCustomRecordValueService.selectProProductCustomRecordValueList(proProductCustomRecordValue);
        return getDataTable(list);
    }

    /**
     * 导出商品属性值对照列表
     */
    @RequiresPermissions("product:productCustomRecordValue:export")
    @Log(title = "商品属性值对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProProductCustomRecordValue proProductCustomRecordValue)
    {
        List<ProProductCustomRecordValue> list = proProductCustomRecordValueService.selectProProductCustomRecordValueList(proProductCustomRecordValue);
        ExcelUtil<ProProductCustomRecordValue> util = new ExcelUtil<ProProductCustomRecordValue>(ProProductCustomRecordValue.class);
        return util.exportExcel(list, "productCustomRecordValue");
    }

    /**
     * 新增商品属性值对照
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商品属性值对照
     */
    @RequiresPermissions("product:productCustomRecordValue:add")
    @Log(title = "商品属性值对照", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProProductCustomRecordValue proProductCustomRecordValue)
    {
        return toAjax(proProductCustomRecordValueService.insertProProductCustomRecordValue(proProductCustomRecordValue));
    }

    /**
     * 修改商品属性值对照
     */
    @GetMapping("/edit/{productCustomRecordValueId}")
    public String edit(@PathVariable("productCustomRecordValueId") Long productCustomRecordValueId, ModelMap mmap)
    {
        ProProductCustomRecordValue proProductCustomRecordValue = proProductCustomRecordValueService.selectProProductCustomRecordValueById(productCustomRecordValueId);
        mmap.put("proProductCustomRecordValue", proProductCustomRecordValue);
        return prefix + "/edit";
    }

    /**
     * 修改保存商品属性值对照
     */
    @RequiresPermissions("product:productCustomRecordValue:edit")
    @Log(title = "商品属性值对照", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProProductCustomRecordValue proProductCustomRecordValue)
    {
        return toAjax(proProductCustomRecordValueService.updateProProductCustomRecordValue(proProductCustomRecordValue));
    }

    /**
     * 删除商品属性值对照
     */
    @RequiresPermissions("product:productCustomRecordValue:remove")
    @Log(title = "商品属性值对照", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(proProductCustomRecordValueService.deleteProProductCustomRecordValueByIds(ids));
    }
}
